$(function () {
    $.post(linkGetList,{},function (text) {
        let data = JSON.parse(text);
        console.log(data);
        console.log(data.status);
        if (data.status==="success"){
            let d = data.data;
            for (const x in d) {
                let p = d[x];
                let checked = p.checked==="yes" ? "checked=\"checked\"":"";
                let list = $("div.renw");
                list.html(list.html()+`<a href="${linkTake}&id=${p.xcid}"><div class="x_renw"><input onclick="checkboxChange('${p.xcid}')" type="checkbox" id="${p.xcid}_checked" ${checked}><div class="name"><h2>${p.name}</h2></div><div class="time">${p.time}</div></div></a>`);
            }
            $("div.renw h1").hide();
        }else if (data.status==="fail"){
            alert("数据读取失败");
        }
    })
});
function checkboxChange(xcid) {
    let checked = document.getElementById(xcid+"_checked").checked ? "yes" : "no";
    $.post(linkSaveCheck,{
        id:xcid,
        checked:checked
    },function (text) {
        location.reload();
    })
}
